package com.company.learnjpa.view;

import jakarta.faces.view.ViewScoped;
import jakarta.inject.Inject;
import jakarta.inject.Named;
import jakarta.security.enterprise.SecurityContext;
import java.io.Serializable;

/**
 *
 * @author xiaolei
 */
@Named(value = "securityInfoView")
@ViewScoped
public class SecurityInfoView implements Serializable {

    @Inject
    private SecurityContext securityContext;

    public SecurityInfoView() {
    }

    public String getMessage() {
        return securityContext.getCallerPrincipal().getName() + " : "
                + securityContext.isCallerInRole("user");
    }
}
